/**
 * 
 */
package net.cloudcodex.client.character.view.panel;

import java.util.ArrayList;
import java.util.List;

import net.cloudcodex.client.character.view.CharactersNoteView;
import net.cloudcodex.client.character.view.CharactersView.Message;

import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.Label;

/**
 * @author Daniel
 * 
 */
public class CharacterSheetNotesPanel extends FlowPanel {

	private boolean isOwner;
	private boolean isGameMaster;
	private Message message;
	private FlowPanel personalNotesPanel = new FlowPanel();
	private FlowPanel playersNotesPanel = new FlowPanel();
	private CharactersNoteView personalCharacterNoteView;
	private List<CharactersNoteView> playerCharacterNoteViews = new ArrayList<CharactersNoteView>();

	/**
	 * 
	 */
	public CharacterSheetNotesPanel() {

	}

	public void setOwner(boolean isOwner) {
		this.isOwner = isOwner;
	}

	public void setGameMaster(boolean isGameMaster) {
		this.isGameMaster = isGameMaster;
	}

	public void setMessage(Message message) {
		this.message = message;
	}

	public void initComponent() {
		initPersonalPanel();
		if (playerCharacterNoteViews != null && !playerCharacterNoteViews.isEmpty()){
			initPlayerNotesPanel();
		}


	}

	private void initPlayerNotesPanel() {
		Label title = new Label(message.getPlayersNotes());
		title.setStyleName("titlePanel");
		playersNotesPanel.add(title);

		for (CharactersNoteView noteView : playerCharacterNoteViews) {
			playersNotesPanel.add(noteView);
		}

		this.add(playersNotesPanel);
	}

	private void initPersonalPanel() {
		Label title;
		if (isGameMaster) {
			title = new Label(message.getGamaMasterPersonnalNotes());
		} else {
			title = new Label(message.getPersonnalNotes());

		}
		title.setStyleName("titlePanel");
		personalNotesPanel.add(title);
		personalNotesPanel.add(personalCharacterNoteView);
		this.add(personalNotesPanel);
	}

	public void addPersonalNotes(CharactersNoteView charactersNoteView) {
		this.personalCharacterNoteView = charactersNoteView;

	}

	public void addPlayersNotes(CharactersNoteView charactersNoteView) {
		this.playerCharacterNoteViews.add(charactersNoteView);
	}

	
	
}
